<template>
  <div class="stars-bar">
    <span class="material-icons" v-for="(v, i) of list" :key="i" :class="{ active: v }">star_rate</span>
    <span class="text">{{ text || value }}</span>
  </div>
</template>

<script>
export default {
  props: {
    value: { type: Number, default: 0 },
    text: { type: String }
  },
  computed: {
    list () {
      return [...Array(5)].map((a, i) => Math.ceil(this.value) >= i)
    }
  },
}
</script>

<style scoped>
.stars-bar {
  display: flex;
  align-items: center;
  flex: auto;
  /* overflow: hidden; */
}
.stars-bar .material-icons {
  color: #e5e5e5;
  font-size: 24rpx;
  margin-right: 3rpx;
  width: 24rpx;
  flex: auto;
}
.stars-bar .material-icons.active {
  color: #feb630;
}
.stars-bar .text {
  color: #aaa;
  font-size: 18rpx;
}
</style>
